package com.xinsoft.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinsoft.entity.dto.QuaCheckItemParam;
import com.xinsoft.entity.po.QuaCheckItem;
import com.xinsoft.mapper.QuaCheckItemMapper;
import com.xinsoft.service.QuaCheckItemService;
import org.springframework.stereotype.Service;

/**
* @author lijie
* @description 针对表【qua_check_item(检验项目)】的数据库操作Service实现
* @createDate 2023-07-18 12:46:33
*/
@Service
public class QuaCheckItemServiceImpl extends ServiceImpl<QuaCheckItemMapper, QuaCheckItem>
    implements QuaCheckItemService{

    @Override
    public Object findPageListByParam(QuaCheckItemParam param) {
        //分页
        Page<QuaCheckItem> page = new Page<QuaCheckItem>(param.getCurrentPage(), param.getPageSize());
        QueryWrapper<QuaCheckItem> queryWrapper = new QueryWrapper<>();
        //查询条件
        if(StrUtil.isNotBlank(param.getCheckItemName())){
            queryWrapper.like("check_item_name", param.getCheckItemName());
        }
        //查询条件-是否启用
        if(param.getDoAble() != null){
            queryWrapper.eq("do_able", param.getDoAble());
        }
        queryWrapper.orderByDesc("update_time");
        IPage<QuaCheckItem> resultPage = this.baseMapper.selectPage(page, queryWrapper);
        //返回值
        return resultPage;
    }
}




